/*******************************************************************************
 * Copyright (c) 2020 THALES GLOBAL SERVICES.
 *  
 *  This program and the accompanying materials are made available under the
 *  terms of the Eclipse Public License 2.0 which is available at
 *  http://www.eclipse.org/legal/epl-2.0
 *  
 *  SPDX-License-Identifier: EPL-2.0
 *  
 *  Contributors:
 *     Thales - initial API and implementation
 ******************************************************************************/
/*
 * generated by Xtext 2.18.0.M3
 */
package org.polarsys.capella.scenario.editor.dsl.ide.contentassist.antlr;

import com.google.common.collect.ImmutableMap;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.util.Map;
import org.eclipse.xtext.AbstractElement;
import org.eclipse.xtext.ide.editor.contentassist.antlr.AbstractContentAssistParser;
import org.polarsys.capella.scenario.editor.dsl.ide.contentassist.antlr.internal.InternalTextualScenarioParser;
import org.polarsys.capella.scenario.editor.dsl.services.TextualScenarioGrammarAccess;

public class TextualScenarioParser extends AbstractContentAssistParser {

	@Singleton
	public static final class NameMappings {
		
		private final Map<AbstractElement, String> mappings;
		
		@Inject
		public NameMappings(TextualScenarioGrammarAccess grammarAccess) {
			ImmutableMap.Builder<AbstractElement, String> builder = ImmutableMap.builder();
			init(builder, grammarAccess);
			this.mappings = builder.build();
		}
		
		public String getRuleName(AbstractElement element) {
			return mappings.get(element);
		}
		
		private static void init(ImmutableMap.Builder<AbstractElement, String> builder, TextualScenarioGrammarAccess grammarAccess) {
			builder.put(grammarAccess.getParticipantAccess().getAlternatives(), "rule__Participant__Alternatives");
			builder.put(grammarAccess.getGenericComponentAccess().getAlternatives(), "rule__GenericComponent__Alternatives");
			builder.put(grammarAccess.getGenericFunctionAccess().getAlternatives(), "rule__GenericFunction__Alternatives");
			builder.put(grammarAccess.getElementAccess().getAlternatives(), "rule__Element__Alternatives");
			builder.put(grammarAccess.getMessageAccess().getAlternatives(), "rule__Message__Alternatives");
			builder.put(grammarAccess.getSequenceMessageTypeAccess().getAlternatives(), "rule__SequenceMessageType__Alternatives");
			builder.put(grammarAccess.getLostFoundMessageAccess().getAlternatives(), "rule__LostFoundMessage__Alternatives");
			builder.put(grammarAccess.getCombinedFragmentAccess().getKeywordAlternatives_0_0(), "rule__CombinedFragment__KeywordAlternatives_0_0");
			builder.put(grammarAccess.getStateFragmentAccess().getKeywordAlternatives_2_0(), "rule__StateFragment__KeywordAlternatives_2_0");
			builder.put(grammarAccess.getModelAccess().getGroup(), "rule__Model__Group__0");
			builder.put(grammarAccess.getActorAccess().getGroup(), "rule__Actor__Group__0");
			builder.put(grammarAccess.getComponentAccess().getGroup(), "rule__Component__Group__0");
			builder.put(grammarAccess.getConfigurationItemAccess().getGroup(), "rule__ConfigurationItem__Group__0");
			builder.put(grammarAccess.getFunctionAccess().getGroup(), "rule__Function__Group__0");
			builder.put(grammarAccess.getActivityAccess().getGroup(), "rule__Activity__Group__0");
			builder.put(grammarAccess.getEntityAccess().getGroup(), "rule__Entity__Group__0");
			builder.put(grammarAccess.getRoleAccess().getGroup(), "rule__Role__Group__0");
			builder.put(grammarAccess.getSequenceMessageAccess().getGroup(), "rule__SequenceMessage__Group__0");
			builder.put(grammarAccess.getCreateMessageAccess().getGroup(), "rule__CreateMessage__Group__0");
			builder.put(grammarAccess.getDeleteMessageAccess().getGroup(), "rule__DeleteMessage__Group__0");
			builder.put(grammarAccess.getArmTimerMessageAccess().getGroup(), "rule__ArmTimerMessage__Group__0");
			builder.put(grammarAccess.getLostMessageAccess().getGroup(), "rule__LostMessage__Group__0");
			builder.put(grammarAccess.getFoundMessageAccess().getGroup(), "rule__FoundMessage__Group__0");
			builder.put(grammarAccess.getParticipantDeactivationAccess().getGroup(), "rule__ParticipantDeactivation__Group__0");
			builder.put(grammarAccess.getCombinedFragmentAccess().getGroup(), "rule__CombinedFragment__Group__0");
			builder.put(grammarAccess.getOperandAccess().getGroup(), "rule__Operand__Group__0");
			builder.put(grammarAccess.getBlockAccess().getGroup(), "rule__Block__Group__0");
			builder.put(grammarAccess.getStateFragmentAccess().getGroup(), "rule__StateFragment__Group__0");
			builder.put(grammarAccess.getReferenceAccess().getGroup(), "rule__Reference__Group__0");
			builder.put(grammarAccess.getModelAccess().getBeginAssignment_1(), "rule__Model__BeginAssignment_1");
			builder.put(grammarAccess.getModelAccess().getParticipantsAssignment_2(), "rule__Model__ParticipantsAssignment_2");
			builder.put(grammarAccess.getModelAccess().getElementsAssignment_3(), "rule__Model__ElementsAssignment_3");
			builder.put(grammarAccess.getModelAccess().getEndAssignment_4(), "rule__Model__EndAssignment_4");
			builder.put(grammarAccess.getActorAccess().getKeywordAssignment_0(), "rule__Actor__KeywordAssignment_0");
			builder.put(grammarAccess.getActorAccess().getNameAssignment_1(), "rule__Actor__NameAssignment_1");
			builder.put(grammarAccess.getComponentAccess().getKeywordAssignment_0(), "rule__Component__KeywordAssignment_0");
			builder.put(grammarAccess.getComponentAccess().getNameAssignment_1(), "rule__Component__NameAssignment_1");
			builder.put(grammarAccess.getConfigurationItemAccess().getKeywordAssignment_0(), "rule__ConfigurationItem__KeywordAssignment_0");
			builder.put(grammarAccess.getConfigurationItemAccess().getNameAssignment_1(), "rule__ConfigurationItem__NameAssignment_1");
			builder.put(grammarAccess.getFunctionAccess().getKeywordAssignment_0(), "rule__Function__KeywordAssignment_0");
			builder.put(grammarAccess.getFunctionAccess().getNameAssignment_1(), "rule__Function__NameAssignment_1");
			builder.put(grammarAccess.getActivityAccess().getKeywordAssignment_0(), "rule__Activity__KeywordAssignment_0");
			builder.put(grammarAccess.getActivityAccess().getNameAssignment_1(), "rule__Activity__NameAssignment_1");
			builder.put(grammarAccess.getEntityAccess().getKeywordAssignment_0(), "rule__Entity__KeywordAssignment_0");
			builder.put(grammarAccess.getEntityAccess().getNameAssignment_1(), "rule__Entity__NameAssignment_1");
			builder.put(grammarAccess.getRoleAccess().getKeywordAssignment_0(), "rule__Role__KeywordAssignment_0");
			builder.put(grammarAccess.getRoleAccess().getNameAssignment_1(), "rule__Role__NameAssignment_1");
			builder.put(grammarAccess.getSequenceMessageAccess().getSourceAssignment_0(), "rule__SequenceMessage__SourceAssignment_0");
			builder.put(grammarAccess.getSequenceMessageAccess().getArrowAssignment_1(), "rule__SequenceMessage__ArrowAssignment_1");
			builder.put(grammarAccess.getSequenceMessageAccess().getTargetAssignment_2(), "rule__SequenceMessage__TargetAssignment_2");
			builder.put(grammarAccess.getSequenceMessageAccess().getExecutionAssignment_3(), "rule__SequenceMessage__ExecutionAssignment_3");
			builder.put(grammarAccess.getSequenceMessageAccess().getReturnAssignment_4(), "rule__SequenceMessage__ReturnAssignment_4");
			builder.put(grammarAccess.getSequenceMessageAccess().getDoubleDotAssignment_5(), "rule__SequenceMessage__DoubleDotAssignment_5");
			builder.put(grammarAccess.getSequenceMessageAccess().getNameAssignment_6(), "rule__SequenceMessage__NameAssignment_6");
			builder.put(grammarAccess.getCreateMessageAccess().getSourceAssignment_0(), "rule__CreateMessage__SourceAssignment_0");
			builder.put(grammarAccess.getCreateMessageAccess().getArrowAssignment_1(), "rule__CreateMessage__ArrowAssignment_1");
			builder.put(grammarAccess.getCreateMessageAccess().getTargetAssignment_2(), "rule__CreateMessage__TargetAssignment_2");
			builder.put(grammarAccess.getCreateMessageAccess().getDoubleDotAssignment_3(), "rule__CreateMessage__DoubleDotAssignment_3");
			builder.put(grammarAccess.getCreateMessageAccess().getNameAssignment_4(), "rule__CreateMessage__NameAssignment_4");
			builder.put(grammarAccess.getDeleteMessageAccess().getSourceAssignment_0(), "rule__DeleteMessage__SourceAssignment_0");
			builder.put(grammarAccess.getDeleteMessageAccess().getArrowAssignment_1(), "rule__DeleteMessage__ArrowAssignment_1");
			builder.put(grammarAccess.getDeleteMessageAccess().getTargetAssignment_2(), "rule__DeleteMessage__TargetAssignment_2");
			builder.put(grammarAccess.getDeleteMessageAccess().getDoubleDotAssignment_3(), "rule__DeleteMessage__DoubleDotAssignment_3");
			builder.put(grammarAccess.getDeleteMessageAccess().getNameAssignment_4(), "rule__DeleteMessage__NameAssignment_4");
			builder.put(grammarAccess.getArmTimerMessageAccess().getArrowAssignment_0(), "rule__ArmTimerMessage__ArrowAssignment_0");
			builder.put(grammarAccess.getArmTimerMessageAccess().getParticipantAssignment_1(), "rule__ArmTimerMessage__ParticipantAssignment_1");
			builder.put(grammarAccess.getArmTimerMessageAccess().getExecutionAssignment_2(), "rule__ArmTimerMessage__ExecutionAssignment_2");
			builder.put(grammarAccess.getArmTimerMessageAccess().getDoubleDotAssignment_3(), "rule__ArmTimerMessage__DoubleDotAssignment_3");
			builder.put(grammarAccess.getArmTimerMessageAccess().getNameAssignment_4(), "rule__ArmTimerMessage__NameAssignment_4");
			builder.put(grammarAccess.getLostMessageAccess().getSourceAssignment_0(), "rule__LostMessage__SourceAssignment_0");
			builder.put(grammarAccess.getLostMessageAccess().getArrowAssignment_1(), "rule__LostMessage__ArrowAssignment_1");
			builder.put(grammarAccess.getLostMessageAccess().getDoubleDotAssignment_2(), "rule__LostMessage__DoubleDotAssignment_2");
			builder.put(grammarAccess.getLostMessageAccess().getNameAssignment_3(), "rule__LostMessage__NameAssignment_3");
			builder.put(grammarAccess.getFoundMessageAccess().getArrowAssignment_0(), "rule__FoundMessage__ArrowAssignment_0");
			builder.put(grammarAccess.getFoundMessageAccess().getTargetAssignment_1(), "rule__FoundMessage__TargetAssignment_1");
			builder.put(grammarAccess.getFoundMessageAccess().getExecutionAssignment_2(), "rule__FoundMessage__ExecutionAssignment_2");
			builder.put(grammarAccess.getFoundMessageAccess().getDoubleDotAssignment_3(), "rule__FoundMessage__DoubleDotAssignment_3");
			builder.put(grammarAccess.getFoundMessageAccess().getNameAssignment_4(), "rule__FoundMessage__NameAssignment_4");
			builder.put(grammarAccess.getParticipantDeactivationAccess().getKeywordAssignment_0(), "rule__ParticipantDeactivation__KeywordAssignment_0");
			builder.put(grammarAccess.getParticipantDeactivationAccess().getNameAssignment_1(), "rule__ParticipantDeactivation__NameAssignment_1");
			builder.put(grammarAccess.getCombinedFragmentAccess().getKeywordAssignment_0(), "rule__CombinedFragment__KeywordAssignment_0");
			builder.put(grammarAccess.getCombinedFragmentAccess().getExpressionAssignment_1(), "rule__CombinedFragment__ExpressionAssignment_1");
			builder.put(grammarAccess.getCombinedFragmentAccess().getOverAssignment_2(), "rule__CombinedFragment__OverAssignment_2");
			builder.put(grammarAccess.getCombinedFragmentAccess().getTimelinesAssignment_3(), "rule__CombinedFragment__TimelinesAssignment_3");
			builder.put(grammarAccess.getCombinedFragmentAccess().getBlockAssignment_4(), "rule__CombinedFragment__BlockAssignment_4");
			builder.put(grammarAccess.getCombinedFragmentAccess().getOperandsAssignment_5(), "rule__CombinedFragment__OperandsAssignment_5");
			builder.put(grammarAccess.getOperandAccess().getKeywordAssignment_0(), "rule__Operand__KeywordAssignment_0");
			builder.put(grammarAccess.getOperandAccess().getExpressionAssignment_1(), "rule__Operand__ExpressionAssignment_1");
			builder.put(grammarAccess.getOperandAccess().getBlockAssignment_2(), "rule__Operand__BlockAssignment_2");
			builder.put(grammarAccess.getBlockAccess().getBeginAssignment_0(), "rule__Block__BeginAssignment_0");
			builder.put(grammarAccess.getBlockAccess().getBlockElementsAssignment_1(), "rule__Block__BlockElementsAssignment_1");
			builder.put(grammarAccess.getBlockAccess().getEndAssignment_2(), "rule__Block__EndAssignment_2");
			builder.put(grammarAccess.getStateFragmentAccess().getOnAssignment_0(), "rule__StateFragment__OnAssignment_0");
			builder.put(grammarAccess.getStateFragmentAccess().getTimelineAssignment_1(), "rule__StateFragment__TimelineAssignment_1");
			builder.put(grammarAccess.getStateFragmentAccess().getKeywordAssignment_2(), "rule__StateFragment__KeywordAssignment_2");
			builder.put(grammarAccess.getStateFragmentAccess().getNameAssignment_3(), "rule__StateFragment__NameAssignment_3");
			builder.put(grammarAccess.getReferenceAccess().getKeywordAssignment_0(), "rule__Reference__KeywordAssignment_0");
			builder.put(grammarAccess.getReferenceAccess().getNameAssignment_1(), "rule__Reference__NameAssignment_1");
			builder.put(grammarAccess.getReferenceAccess().getOverAssignment_2(), "rule__Reference__OverAssignment_2");
			builder.put(grammarAccess.getReferenceAccess().getTimelinesAssignment_3(), "rule__Reference__TimelinesAssignment_3");
		}
	}
	
	@Inject
	private NameMappings nameMappings;

	@Inject
	private TextualScenarioGrammarAccess grammarAccess;

	@Override
	protected InternalTextualScenarioParser createParser() {
		InternalTextualScenarioParser result = new InternalTextualScenarioParser(null);
		result.setGrammarAccess(grammarAccess);
		return result;
	}

	@Override
	protected String getRuleName(AbstractElement element) {
		return nameMappings.getRuleName(element);
	}

	@Override
	protected String[] getInitialHiddenTokens() {
		return new String[] { "RULE_WS", "RULE_ML_COMMENT", "RULE_SL_COMMENT" };
	}

	public TextualScenarioGrammarAccess getGrammarAccess() {
		return this.grammarAccess;
	}

	public void setGrammarAccess(TextualScenarioGrammarAccess grammarAccess) {
		this.grammarAccess = grammarAccess;
	}
	
	public NameMappings getNameMappings() {
		return nameMappings;
	}
	
	public void setNameMappings(NameMappings nameMappings) {
		this.nameMappings = nameMappings;
	}
}
